Skip to content

QTT fundamentals coupling: my-qtt verified-core checker + Idris substitution-algebra slices#116

Merged
hyperpolymath merged 5 commits into
mainfrom
claude/dreamy-hypatia-O8XHo
Jun 18, 2026
Merged

QTT fundamentals coupling: my-qtt verified-core checker + Idris substitution-algebra slices#116
hyperpolymath merged 5 commits into
mainfrom
claude/dreamy-hypatia-O8XHo

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Two strands, both green, advancing the fundamentals → implementation axis.

1. crates/my-qtt — QTT verified-core checker (the coupling, NEW)

proofs/STATUS.md §"Implementation ⇄ spec coupling" records that the mechanised QTT core and the Rust compiler are two disconnected universeschecker.rs (1830 LOC) is a conventional Hindley checker with no usage/multiplicity axis. This crate is the first concrete bridge: a faithful Rust port of the machine-checked Coq usage-walk synthesiser (SoloCore.v rung R5 check / R5b aff_type_dec).

  • Q semiring {0,1,ω} (qadd/qmul/qle) — Coq Quantity.v tables verbatim
  • usage vectors (uzero/onehot/uadd/uscale/ule)
  • check : Tctx -> Tm -> Option<(Ty, Uvec)> — the one-pass synthesiser (SoloCore.v:2128), returning the type and the exact realised usage
  • aff_check — the affine-budget decision (aff_type_dec / aff_type_iff, R5b)
  • de Bruijn faithful (snoc-list ↔ Vec, innermost = last)
  • 7 tests green, incl. the 4 SoloCore.v reflexivity Examples reproduced as oracle tests (check_id_unit / drop_linear / dup_linear / dup_omega) + the R5b affine discard — so the port is checked against the verified algorithm's own closed computations. No external deps.

2. Idris substitution-algebra slices (toward #108 preservation)

The accounting layer beneath htSubst, all --build-checked, hole-free, %default total (these were built after #115 and are not yet on main):

  • A1 — shiftn, htShift0, qReassoc (via the named semiring laws, no 3⁶ enumeration), uaddUscaleZeroR
  • A2 — vecReassoc, substReassocAdd, substReassocMult (the affine-accounting reassociation)
  • A3 — usplit3, uaddSplitBoundary2, substVarSucc
  • B — hvSubst (the variable case of the QTT substitution lemma)

htSubst (the 15-case main lemma) + subst2Lemma + preservation remain the open tail of #108; a working draft is parked locally.

Test plan

  • cargo test -p my-qtt → 7 passed (no LLVM toolchain needed)
  • Idris idris2 --build solo-core.ipkg exits 0, only ?todo_preservation hole
  • Coq track unchanged

Next coupling step

Elaborate the my-lang surface AST onto the my-qtt core so the running checker enforces the resource axis (today it doesn't). Then targets per the roadmap (LLVM wasm32 → RISC-V → mobile; typed-wasm WasmGC as the verified leg).

Refs #108, proofs/STATUS.md

🤖 Generated with Claude Code


Generated by Claude Code

@hyperpolymath
hyperpolymath marked this pull request as ready for review June 17, 2026 23:08
@hyperpolymath
hyperpolymath enabled auto-merge (rebase) June 17, 2026 23:10
claude added 5 commits June 17, 2026 23:12
…ward #108)

First slice of the htSubst -> preservation port (Coq SoloCore.v is the
blueprint). Lands the scalar/accounting foundation, all green under
%default total, hole-free:

  - shiftn            iterated weakening shift
  - htShift0          one-binder weakening (htShift at I=TEmpty)
  - qAddRearrange     middle-four exchange for qAdd
  - qReassoc          the Q-semiring identity behind additive-split subst,
                      via the named semiring laws (no 3^6 enumeration)
  - uaddUscaleZeroR   Zero-scaled summand is the additive identity

Refs #108
… toward #108)

The affine-accounting heart of ht_subst, all green under %default total:

  - combMaybe / uaddUSnocReduce / uaddSnocSplit  USnoc-tail uadd helpers
  - vecReassoc        lifts qReassoc to usage vectors (Maybe-equation form)
  - substReassocAdd   additive-split residual combine (uaddTotal + vecReassoc)
  - substReassocMult  multiplicative-split variant (q'=One)

Mirrors Coq vec_reassoc / subst_reassoc_add / subst_reassoc_mult. Refs #108
…, toward #108)

Completes the substitution accounting algebra, all green under %default total:

  - usplit3            USnoc-boundary usage split by length (drops unused
                       ulen-dg conjunct vs Coq usplit3)
  - uaddSplitBoundary2 USnoc-headed boundary sum split (heads add: q=q1+q2)
  - substVarSucc       deeper-index subst commutes with one weakening shift
                       (GT case needs minusZeroRight to bridge the stuck minus)

Mirrors Coq usplit3 / uadd_split_boundary2 / subst_var_succ. With A1+A2+A3
the full accounting layer beneath hvSubst/htSubst is done. Refs #108
…#108)

The variable case of the QTT substitution lemma (mirrors Coq hv_subst), green
under %default total. Prefix-I induction; matches n=Z/S n0 at runtime and
bridges varInv's erased witness via predEq'. Two leaves:
  - substituted variable itself  -> returns u, usage scaled by q (uaddZeroL)
  - any other variable           -> unchanged, Zero-scaled (uaddUscaleZeroR),
                                     re-weakened by htShift0 + substVarSucc

Refs #108
…5/R5b

First strand of the fundamentals -> implementation coupling (the path the user
chose). proofs/STATUS.md flags that the mechanised QTT core and the Rust
compiler are 'two disconnected universes': checker.rs is a conventional Hindley
checker with no usage/multiplicity axis. This new crate ports the
machine-checked usage-walk synthesiser into the compiler's own language:

  - Q semiring {0,1,ω} (qadd/qmul/qle) — Coq Quantity.v tables verbatim
  - usage vectors (uzero/onehot/uadd/uscale/ule) — Coq SoloCore.v
  - check : Tctx -> Tm -> Option<(Ty,Uvec)> — the one-pass synthesiser
    (SoloCore.v:2128), returning the type AND exact realised usage
  - aff_check — the affine-budget decision (aff_type_dec / aff_type_iff, R5b)

Faithful de Bruijn (snoc-list <-> Vec, innermost = last). 7 tests green,
incl. the 4 SoloCore.v 'reflexivity' Examples reproduced as oracle tests
(check_id_unit / drop_linear / dup_linear / dup_omega) + the R5b affine
discard — so the port is checked against the verified algorithm's own
closed computations. No external deps; cargo test -p my-qtt passes.

Next coupling step: elaborate the my-lang surface AST onto this core so the
running checker enforces the resource axis. Refs proofs/STATUS.md.
@hyperpolymath
hyperpolymath force-pushed the claude/dreamy-hypatia-O8XHo branch from c0c6418 to da9363c Compare June 17, 2026 23:13
@hyperpolymath
hyperpolymath disabled auto-merge June 18, 2026 00:11
@hyperpolymath
hyperpolymath merged commit f2eff3b into main Jun 18, 2026
15 of 17 checks passed
@hyperpolymath
hyperpolymath deleted the claude/dreamy-hypatia-O8XHo branch June 18, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants